<!-- 课程详情 -->
<template>
	<z-paging ref="paging" v-model="dataList" @query="queryList" v-if="isshow"
	class="box">
		<!-- 讲师介绍 -->
		<!-- <template #top> -->
			<view class="info">
				<view class="title">
					<view class="line"></view>
					<text>讲师介绍</text>
				</view>
				<view class="content">
					<view class="left">
						<avatar :src="info.imgUrl" class="avatar"></avatar>
					</view>
					<view class="right">
						<view class="title">{{info.realName}}<text>{{info.lecturerLable}}</text></view>
						<view class="brief clamp2">{{info.introduction}}</view>
					</view>
				</view>
			</view>
			<view class="list">
				<view class="title">
					<view class="line"></view>
					<view>课程列表({{dataList.length}}/{{ total}}节)</view>
				</view>
			</view>
		<!-- </template> -->
		<view class="data">
			<view class="item" v-for="(item,index) in dataList" :key="index" @click="goDetail(item.id)">
				<view class="top">
					<image class="img" :src="item.coverImg" mode=""></image>
					<view class="words">
						<view class="name">
							{{item.resourceName}}
						</view>
						<view class="status">
							已购买
						</view>
					</view>
				</view>
				<view class="down">
					<view class="left">
						讲师：<text>{{item.lecturerName}}</text>
					</view>
					<view class="right">
						<view class="icon">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/watch.png"></image>
							<text>{{item.watchNum}}</text>
						</view>
						<view class="icon">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/praiseIcon.png"></image>
							<text>{{item.greatNum}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script>
	import {
		seriesDetail,
		resourceList,
		chapterList
	} from '@/apis/apis.js'
	import avatar from '@/components/avatar.vue'
	export default {
		components: {
			avatar
		},
		data() {
			return {
				id: "",
				info: {},
				dataList: [],
				total: 0,
				isshow:false
			}
		},
		onLoad(options) {
			this.id = options.id ? options.id : ""
			this.total = options.total
		},
		onShow() {
			this.isshow = true
		},
		onHide() {
			this.isshow = false
		},
		methods: {
			queryList(pageNo, pageSize) {
				seriesDetail(this.id).then(res => {
					console.log(res)
					this.info = res.data
					chapterList({
						pageNum: pageNo,
						pageSize: pageSize,
						courseId: this.info.id
					}).then(res => {
						console.log(res)
						this.$refs.paging.complete(res.data);
					})
				})

			},
			goDetail(e) {
				let backDetail=true
				uni.navigateTo({
					url: `/pages/index/courseItem/courseItem?id=${e}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		background-color: #F8F8F8;
	}

	.info,
	.list {
		padding: 8rpx 32rpx 0 30rpx;
		background-color: #F8F8F8;

		.line {
			width: 10rpx;
			height: 26rpx;
			background-color: #194FC9;
			border-radius: 4rpx;
			margin-right: 12rpx;
		}

		&>.title {
			display: flex;
			align-items: center;
			color: #303030;
			font-weight: bold;
			font-size: 32rpx;
		}
	}


	.info {
		padding-top: 32rpx;
		.content {
			background-color: #fff;
			border-radius: 20rpx;
			padding: 30rpx 53rpx 28rpx 26rpx;
			display: flex;
			justify-content: space-between;
			margin-top: 28rpx;
			box-sizing: border-box;

			.left {
				.avatar {
					width: 140rpx;
					height: 140rpx;
					border-radius: 10rpx;
					margin-right: 32rpx;
				}
			}

			.right {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					font-size: 30rpx;
					color: #111111;
					font-weight: bold;
					display: flex;
					align-items: center;

					text {
						font-weight: 400;
						color: rgb(83, 163, 255);
						font-size: 24rpx;
						background-color: rgb(234, 248, 255);
						padding: 10rpx;
						margin-left: 10rpx;
						border-radius: 10rpx;
					}
				}

				.brief {
					color: #939393;
					height: 72rpx;
					width: 438rpx;
					font-size: 28rpx;
				}
			}
		}
	}

	.list {
		padding-top: 38rpx;
	}

	.data {
		padding: 26rpx 30rpx 0;

		.item {
			height: 240rpx;
			padding: 25rpx 25rpx 16rpx 25rpx;
			background: #FFFFFF;
			box-shadow: 0 7rpx 27rpx 0 rgba(127, 129, 133, 0.15);
			border-radius: 20rpx;
			margin-bottom: 24rpx;

			.top {
				display: flex;

				.img {
					width: 220rpx;
					height: 147rpx;
					border-radius: 15rpx;
				}

				.words {
					margin-left: 31rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-around;

					.name {
						font-size: 30rpx;
						font-weight: 500;
						color: #111111;
					}

					.status {
						font-size: 26rpx;
						font-weight: 500;
						color: #B0B0B0;
					}
				}
			}

			.down {
				margin-top: 25rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					font-size: 26rpx;
					color: #4A4A4A;

					&>text {
						color: #B2B2B2;
					}
				}

				.right {
					display: flex;
					align-items: center;

					.icon {
						margin: 0 25rpx;

						&>image {
							width: 27rpx;
							height: 17rpx;
						}

						&>text {
							font-size: 24rpx;
							color: #B0B0B0;
						}
					}
				}
			}
		}
	}
</style>
